<template>
	<comRoot>
		<template #page>
			
			<image v-if="commonConfigs && commonConfigs.domainFrontFileLink" :src="`${commonConfigs.domainFrontFileLink}/files/images/page-bg.png`" class="bg" />
			
			<comDetailNavigateBack title="记录页" />

			<comScrollTab v-model="tabIndex" :list="tabAreaList">
				<scroll-view scroll-y @scrolltolower="scrolltolower" :style="{height: 'calc(100vh - ' + commonNavHeight + ' - 120rpx)'}">
					<!-- 中奖记录 -->
					<view v-if="tabIndex === 0">
						<view v-if="resLists && resLists.length">
							<comHousePrizeRecord :resLists="resLists" />
							<comLoadMore :loading="loading" :showLoadendTxt="showLoadendTxt" class="loadmore-txt"></comLoadMore>
						</view>
						<comEmptyData v-else></comEmptyData>
					</view>
					
					<!-- 参与记录 -->
					<view v-if="tabIndex === 1">
						<view v-if="resLists && resLists.length">
							<comHouseJoinRecord :resLists="resLists" />
							
							<comLoadMore :loading="loading" :showLoadendTxt="showLoadendTxt" class="loadmore-txt"></comLoadMore>
						</view>
						<comEmptyData v-else></comEmptyData>
					</view>
				</scroll-view>
			</comScrollTab>
		</template>
	</comRoot>
</template>

<script>
	import { getWelfareHouseLogApi } from '@/setupproject/INTERFACE.js';
	import pager from '@/inmixed/paging.mixin.js';

	import store from '@/store';
	export default {
		name: 'awardRecordPage',
		mixins: [pager],
		data() {
			return {
				tabAreaList: [
					{
						type: 1,
						text: '中奖记录',
					},
					{
						type: 2,
						text: '参与记录',
					}
				],
				loading: false,
				tabIndex: 0,
				
			};
		},
		watch: {
			tabIndex() {
				/* paging.mixin.js Methods */
				this.pagingInitFun();
				this.resListsGetFun();
			}
		},
		computed: {
			commonNavHeight() {
				return store.getters.commonNavHeight + 'px';
			},
			commonConfigs() {
				return store.getters.commonConfigs || {};
			},
			showLoadendTxt() {
				return this.isShowPageLoadedTxt && !this.loading && this.resLists.length ? true : false;
			},
		},
		methods: {
			/* 需要固定为listsGetFun；以配合 paging.mixin */
			async listsGetFun() {
				this.loading = true

				const { data, code } = await getWelfareHouseLogApi({ 
					type: this.tabAreaList[this.tabIndex].type, 
					page_size: this.pageInfoObj.page_size, 
					page: this.pageInfoObj.page ,
				});
				
				this.loading = false;
				
				if (code !== 200) return false;
				
				data.resLists = data.rows;
				
				return data;
			}
		}
	};
</script>

<style></style>
